package cn.tedu.micro.demo.rabbitmq.base.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.*;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@Slf4j
public class DeclareConfig {
    @Bean
    public Queue demoQueue() {
        //channel.queueDeclare("demo-queue",false,false,false,null)
        QueueBuilder queueBuilder = QueueBuilder.nonDurable("demo-queue");
        return queueBuilder.build();
    }
    @Bean
    public Exchange demoExchange() {
//        channel.exchangeDeclare("demo-ex", "direct",false,false,null);
        ExchangeBuilder exchangeBuilder = ExchangeBuilder.fanoutExchange("demo-ex");
        return exchangeBuilder.build();
    }
    @Bean
    public Binding demoBinding() {
        //channel.queueBind("demo-queue","demo-ex","");
        BindingBuilder.GenericArgumentsConfigurer bindingBuilder =
                BindingBuilder.bind(demoQueue()).to(demoExchange()).with("");
        return bindingBuilder.noargs();
    }
}
